import {ElMessage, ElMessageBox} from "element-plus"
import {h}                       from "vue"

export function AreYouSure() {
    return new Promise((resolve) => {
        let random   = Math.floor(Math.random() * 10000).toString()
        let alarmTip = h("div", null, [
            h("span", null, "请输入:("),
            h("span", {style: "color: red"}, random),
            h("span", null, ")以继续"),
        ])

        ElMessageBox.prompt(alarmTip, "你确认么?", {
            confirmButtonText: "继续",
            cancelButtonText : "取消",
        }).then(({value}) => {
            if (value === random) {
                resolve(random)
            }
            else {
                ElMessage.warning("输入错误")
            }
        }).catch(e => {
        })
    })
}

